package benworks.bookcode.jppo.chapter5;

import org.junit.Test;

import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.NotFoundException;

/**
 * VM args: -XX:PermSize=2M -XX:MaxPermSize=4M -XX:+PrintGCDetails
 * @author Ben
 */
public class JavaBeanObjectTest {

	public static void main(String[] args)
			throws CannotCompileException, NotFoundException, InstantiationException, IllegalAccessException {
		for (int i = 0; i < Integer.MAX_VALUE; i++) {
			CtClass c = ClassPool.getDefault().makeClass("Geym" + i);
			c.setSuperclass(ClassPool.getDefault().get("benworks.bookcode.jppo.chapter5.JavaBeanObject"));
			Class<?> clz = c.toClass();
			JavaBeanObject v = (JavaBeanObject) clz.newInstance();
//			System.out.println("class" + c.getName());
		}
	}
	
	@Test
	public void getOneClassLoad()
			throws CannotCompileException, NotFoundException, InstantiationException, IllegalAccessException {
		for (int i = 0; i < Integer.MAX_VALUE; i++) {
			CtClass c = ClassPool.getDefault().makeClass("Geym" + i);
			c.setSuperclass(ClassPool.getDefault().get("benworks.bookcode.jppo.chapter5.JavaBeanObject"));
			Class<?> clz = c.toClass();
			JavaBeanObject v = (JavaBeanObject) clz.newInstance();
			System.out.println("class" + c.getName());
		}
	}
}
